const util = require('../../../utils/util.js')
// pages/appoint/appoint-detail/appoint-detail.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        case: 0,
        url: '',
        docid: 0,
        currentTemp: {},
        tempData: {},
        outcallsData: [{hname: '小白'}],
        outcalls: [{outid: '1', dt: '今天'}, {outid: '2', dt: '明天'}, {outid: '3', dt: '后天'}, {outid: '4', dt: '大后天'}],
        hidden: true,
        isShow: false,

    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        var uid = this.data.docid
        console.log("appoint" + uid)
        util.http('/wx/doctorid?uid=' + uid, resp => {
            console.log(resp)
            if (resp.code == 1) {
                this.data.tempData = resp.doctorbean
            }
            this.setData(this.data)
        })
        var id = wx.getStorageSync('id');
        util.http('/wx/doctoryuyue?pid=' + id + '&did=' + uid, resp => {
            console.log(resp + "docyuyue")
            if (resp.code == 1) {
                this.data.hidden = true
                console.log(this.data.case + "CASE")
                if (this.data.case == 0) {
                    this.data.isShow = true
                }
            } else {
                this.data.hidden = false
                this.data.isShow = false
            }
            this.setData(this.data)
        })
    },
    clickTap: function (e) {
        console.log(e.currentTarget.dataset.oid)
        var index = e.currentTarget.dataset.oid
        var id = wx.getStorageSync('id')
        var docid = this.data.docid
        console.log(index + "  " + id + "  " + docid)
        util.http('/wx/yuyue?id=' + id + '&uid=' + docid + '&index=' + index, resp => {
            console.log(resp)
            if (resp.code == 1) {
                this.data.hidden = false
                this.data.tempData = resp.doctorbean
                this.data.isShow = true
            }
            this.setData(this.data)
        })
        wx.navigateTo({

            url: '../appoint-ok/appoint-ok'
        })
    }, onLoad(e) {
        console.log(e.id + "----")
        this.data.docid = e.id
        if (e.case) {
            this.data.case = e.case
        }

        console.log(e.case + "e.case")
        this.setData(this.data)
    }, clicktt() {
        util.alert("请不要点击了,你已经预约过了")
    }, cancel() {
        setTimeout(() => {
            wx.navigateBack()//推出当前页面
        }, 500)
        console.log("取消")
    }, appointok() {
        console.log("成功")
        console.log(this.data.docid)
        var exid = this.data.docid
        var case1 = 1
        wx.navigateTo({
            url: '../appoint-detail/appoint-detail?id=' + exid + '&case=' + case1
        })
    }

})